<?php

namespace App\Console\Commands;

use App\Imports\OrderImport;
use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;

class ImportOrders extends Command
{
    const FILE_NAME = ''; // you're default excel path

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'import:order {fileName?}';

    /**
     * The console command description.
     *
     *
     * @var string
     */
    protected $description = 'import any order';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $fileName = $this->argument('fileName');

        if (null === $fileName) {
            $fileName = self::FILE_NAME;
        }

        Excel::import(new OrderImport(), $fileName);
    }
}
